﻿using PS.Algorithms;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using PS.DataTypes;
using Microsoft.Xna.Framework;

namespace PS.Test
{
    /// <summary>
    /// This is a test class for CollisionDetectorTest and is intended
    /// to contain all CollisionDetectorTest Unit Tests
    /// </summary>
    [TestClass()]
    public class CollisionDetectorTest
    {
        /// <summary>
        /// A test for Intersects. Result has to be true.
        ///</summary>
        [TestMethod()]
        public void IntersectsTest()
        {
            Line line1 = new Line(new Vector2(300, 250), new Vector2(300, 150));
            Line line2 = new Line(new Vector2(220, 50), new Vector2(500, 200));

            Vector2 intersection = new Vector2();
            Vector2 intersectionExpected = new Vector2(1, 1);
            bool expected = true;
            bool actual;
            actual = CollisionDetector.Intersects(line1, line2, out intersection);
            Assert.AreEqual(intersectionExpected, intersection);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// A test for Intersects. Result has to be false.
        ///</summary>
        [TestMethod()]
        public void IntersectsTestParallel()
        {
            Line line1 = new Line(new Vector2(0, 1), new Vector2(2, 1));
            Line line2 = new Line(new Vector2(1, 2), new Vector2(2, 2));

            Vector2 intersection = new Vector2();
            Vector2 intersectionExpected = new Vector2(1, 1);
            bool expected = false;
            bool actual;
            actual = CollisionDetector.Intersects(line1, line2, out intersection);
            Assert.AreNotEqual(intersectionExpected, intersection);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// A test for Intersects. Result has to be false.
        ///</summary>
        [TestMethod()]
        public void IntersectsTestNegative()
        {
            Line line1 = new Line(new Vector2(1, 0), new Vector2(2, 0));
            Line line2 = new Line(new Vector2(0, 1), new Vector2(0, 2));

            Vector2 intersection = new Vector2();
            Vector2 intersectionExpected = new Vector2(1, 1);
            bool expected = false;
            bool actual;
            actual = CollisionDetector.Intersects(line1, line2, out intersection);
            Assert.AreNotEqual(intersectionExpected, intersection);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Intersects
        ///</summary>
        [TestMethod()]
        public void IntersectsTest1()
        {
            Line line1 = new Line(new Vector2(1, 1), new Vector2(1, 2));
            Line line2 = new Line(new Vector2(1, 3), new Vector2(3, 1));
            Vector2 intersection = new Vector2();
            Vector2 intersectionExpected = new Vector2(); // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = CollisionDetector.Intersects(line1, line2, out intersection);
            Assert.AreEqual(intersectionExpected, intersection);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
